﻿<!DOCTYPE html>
<html>
<head>
<%
    include("/static/include/title.html"){}
    include("/static/include/css.html"){}
    include("/static/include/js.html"){}
%>
</head>
<body>
<div class="layui-fluid">
	<form id="fAdd" class="layui-form" action="#" onsubmit="return false" method="post">
		<input type="hidden" id="dialogId" name="dialogId" value="${parameter.dialogId}"/>
		<div class="layui-card">
			<!-- 如需要header信息，放开下面的comment -->
			<!-- <div class="layui-card-header">基础信息</div> -->
			<div class="layui-card-body" style="padding: 15px;">
				<!-- 如一行显示多列数据，参照下面的示例 -->
				<!--
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">属性1：</label>
						<div class="layui-input-inline">
							<input type="text" autocomplete="off" class="layui-input" maxlength="25" title="属性1对应控件">
						</div>
					</div>对应控件
					<div class="layui-inline">
						<label class="layui-form-label">属性2：</label>
						<div class="layui-input-inline">
							<input type="text" autocomplete="off" class="layui-input" maxlength="25" title="属性1对应控件">
						</div>
					</div>
				</div>
				-->
				<div class="layui-form-item">
					<label class="layui-form-label">父组织<span style="color:#FF5722;">*</span>：</label>
					<div class="layui-input-block">
						<input type="text" name="organization.parent.organizationName" placeholder="选择父组织" value="${organization.parent.organizationName}" autocomplete="off" class="layui-input" maxlength="8" readonly onclick="selectOrganization();"/>
						<input type="hidden" name="organization.parentId" value="${organization.parentId}">
					</div>
				</div>
                <div class="layui-form-item">
                    <label class="layui-form-label">组织名称<span style="color:#FF5722;">*</span>：</label>
                    <div class="layui-input-block">
                        <input type="text" name="organization.organizationName" placeholder="组织名称" value="${@team.bangbang.common.utility.LogicUtility.getQuotedString(organization.organizationName)}" autocomplete="off" class="layui-input" maxlength="50">
                    </div>
                </div>
				<div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">类型<span style="color:#FF5722;">*</span>：</label>
                        <div class="layui-input-inline">
                            <select name="organization.typeFlag">
                                <option value="">--请选择--</option>
                                <% if(has(typeList) && typeList != null) { for(i in typeList) {%>
                                <option value="${i.key}"<% if(organization.typeFlag == i.key) {%> selected<%}%>>${i.value}</option>
                                <%}}%>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">组织编码：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="organization.organizationCode" placeholder="组织编码" value="${organization.organizationCode}" autocomplete="off" class="layui-input" maxlength="5"/>
                        </div>
                    </div>
                </div>
				<div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">简称：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="organization.briefName" placeholder="简称" value="${@team.bangbang.common.utility.LogicUtility.getQuotedString(organization.briefName)}" autocomplete="off" class="layui-input" maxlength="50">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">有效标识<span style="color:#FF5722;">*</span>：</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="organization.activeFlag" value="true" title="有效"<% if(organization.activeFlag != null && organization.activeFlag) {%> checked<%}%>/>
                            <input type="radio" name="organization.activeFlag" value="false" title="无效"<% if(organization.activeFlag == null || !organization.activeFlag) {%> checked<%}%>/>
                        </div>
                    </div>
                </div>
			</div>
		</div>
		<div class="layui-form-item layui-layout-admin">
			<div class="layui-input-block">
				<div class="layui-footer" style="left: 0;">
					<button class="layui-btn" onclick="doAddAction('organization');">新 增</button>
				</div>
			</div>
		</div>
	</form>
</div>
<script>
	layui.use(['form','laydate'], function(){
        var form  = layui.form;
        var laydate = layui.laydate;
        // 渲染表单radio、select、checkbox
        form.render();
    });
	function validate(theForm) {
		// 注意：
		// 如果更改页面表单的控件类型，请在校验判断时做对应修改：
		// 1. 下拉框：使用 $.trim(theForm["控件名称"].value) == ""
		// 2. 单选框/复选框：使用 getChoiceValue("控件名称") == null
		//
		var organizationParentId = $.trim(theForm["organization.parentId"].value);
		if(organizationParentId != "" && !isPositiveInteger(organizationParentId)) {
			layer.msg("请选择父组织！");
			return false;
		}
        if($.trim(theForm["organization.organizationName"].value) == "") {
            $.message("组织名称不能为空！");
            return false;
        }
		var organizationTypeFlag = $.trim(theForm["organization.typeFlag"].value);
		if(organizationTypeFlag == "") {
			$.message("请选择类型！");
			return false;
		}
		if(getChoiceValue("organization.activeFlag") == null) {
			$.message("请选择有效标识！");
			return false;
		}
		return true;
	}
    
    // 选择所在组织
    function selectOrganization() {
        openDialog("组织机构选择", "../basis/organizationSelect.do", 1000, 800, function(result) {
   			console.log(result);
   			var arr = result.data;
   			if(arr == null || arr.length == 0) {
                // 清除
                document.forms[0]["organization.parent.organizationName"].value = "";
                document.forms[0]["organization.parentId"].value = "";
   				return;
   			}

            var orgs = result.data;
            // 获得组织机构编号和名称
            document.forms[0]["organization.parent.organizationName"].value = orgs[0].fullName;
            document.forms[0]["organization.parentId"].value = orgs[0].id;
        });
    }
</script>
</body>
</html>